package com.ruoyi.internet.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.internet.domain.IntNotice;
import com.ruoyi.internet.mapper.IntNoticeMapper;
import com.ruoyi.internet.service.IIntNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资讯公告Service业务层处理
 *
 * @author cjie
 * @date 2021-08-16
 */
@Service
public class IntNoticeServiceImpl implements IIntNoticeService {
    @Autowired
    private IntNoticeMapper intNoticeMapper;

    /**
     * 查询资讯公告
     *
     * @param noticeId 资讯公告ID
     * @return 资讯公告
     */
    @Override
    public IntNotice selectIntNoticeById(Integer noticeId) {
        return intNoticeMapper.selectIntNoticeById(noticeId);
    }

    /**
     * 查询资讯公告列表
     *
     * @param intNotice 资讯公告
     * @return 资讯公告
     */
    @Override
    public List<IntNotice> selectIntNoticeList(IntNotice intNotice) {
        return intNoticeMapper.selectIntNoticeList(intNotice);
    }

    /**
     * 新增资讯公告
     *
     * @param intNotice 资讯公告
     * @return 结果
     */
    @Override
    public int insertIntNotice(IntNotice intNotice) {
        intNotice.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        intNotice.setCreateTime(DateUtils.getNowDate());
        intNotice.setCreateBy(SecurityUtils.getUsername());
        return intNoticeMapper.insertIntNotice(intNotice);
    }

    /**
     * 修改资讯公告
     *
     * @param intNotice 资讯公告
     * @return 结果
     */
    @Override
    public int updateIntNotice(IntNotice intNotice) {
        intNotice.setUpdateTime(DateUtils.getNowDate());
        intNotice.setUpdateBy(SecurityUtils.getUsername());
        return intNoticeMapper.updateIntNotice(intNotice);
    }

    /**
     * 批量删除资讯公告
     *
     * @param noticeIds 需要删除的资讯公告ID
     * @return 结果
     */
    @Override
    public int deleteIntNoticeByIds(Integer[] noticeIds) {
        return intNoticeMapper.deleteIntNoticeByIds(noticeIds);
    }

    /**
     * 删除资讯公告信息
     *
     * @param noticeId 资讯公告ID
     * @return 结果
     */
    @Override
    public int deleteIntNoticeById(Integer noticeId) {
        return intNoticeMapper.deleteIntNoticeById(noticeId);
    }
}
